package com.sky.mapper;

import com.sky.entity.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.Map;

/**
 * 用户接口数据层
 */
@Mapper
public interface UserMapper {

    /**
     * 根据 openid 查询用户
     * @param openid
     * @return
     */
    @Select("select * from user where openid = #{openid} ")
    User getByOpenid(String openid);

    /**
     * 新增用户信息
     * @param user
     */
    void insert(User user);

    /**
     * 根据userId查询用户
     * @param userId
     * @return
     */
    @Select("select * from user where id = #{userId} ")
    User getById(Long userId);

    /**
     * 根据起始日期和结束日期统计用户数量
     * @param map
     * @return
     */
    Integer countByMap(Map map);

    /**
     * 统计当日新增用户数量
     * @param map
     * @return
     */
    @Select("select count(*) from user where create_time <= #{end} and create_time >= #{begin} ")
    Integer getNewUserByDate(Map map);
}
